package com.taotao.controller;

import com.taotao.common.pojo.EUDataGridResult;
import com.taotao.common.pojo.TaotaoResult;
import com.taotao.pojo.TbItem;
import com.taotao.service.ItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Package com.taotao.controller
 * @Description:
 * @Author elwyn
 * @Date 2017/9/2 14:16
 * @Email elonyong@163.com
 */
@Controller
public class ItemController {
    @Autowired
    private ItemService itemService;

    @RequestMapping("/item/{itemId}")
    @ResponseBody
    public TbItem getItemById(@PathVariable Long itemId) {
        TbItem itemById = itemService.getItemById(itemId);
        return itemById;
    }

    @RequestMapping("/item/list")
    @ResponseBody
    public EUDataGridResult getItemById(Integer page, Integer rows) {
        return itemService.getItemList(page, rows);
    }

    @RequestMapping("/item/save")
    @ResponseBody
    public TaotaoResult crateItem(TbItem tbItem, String desc,String itemParams) throws Exception {
        TaotaoResult item = itemService.createItem(tbItem, desc,itemParams);
        return item;

    }
}
